//
//  GoalViewController.m
//  jinnengExam
//
//  Created by mac on 2020/8/17.
//  Copyright © 2020 jznrj. All rights reserved.
//

#import "GoalViewController.h"

@interface GoalViewController ()

@end

@implementation GoalViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"个人积分";
    UINavigationBar * bar = self.navigationController.navigationBar;
    UIImage *bgImage = [ColorUtil navigationBarColor:[ColorUtil titleColor] BarSize:bar.frame alphe:1.0];
    [bar setBackgroundImage:bgImage forBarMetrics:UIBarMetricsDefault];
    [bar setTintColor:[UIColor whiteColor]];
    [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]}forState:UIControlStateNormal];
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,nil]];
    
    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
    
    self.tabBarController.tabBar.frame = CGRectMake(0, 0, 0, 0);
     self.tabBarController.tabBar.hidden = YES;
    // Do any additional setup after loading the view.
    [self initView];
}
-(void) viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden =NO;
}
-(void) initView{
   [self.view addSubview:self.jznWebView];
    [self.jznWebView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.right.equalTo(self.view);
         make.top.bottom.equalTo(self.view);
     }];
    self.jznWebView.scrollView.bounces = NO;
    self.view.backgroundColor = [UIColor whiteColor];
    [self.jznWebView loadLocalFile:@"/ios_jinneng/userPoint" type:@"html"];
    
    [self registerJsFunction];
}

-(void) registerJsFunction{
}

- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{
    [self requestPoint];
}
-(void) requestPoint{
    NSString *url = [NSString stringWithFormat:@"%@/userPoint/findUserPointInfo" ,[URLUtil hostName]];
    NSDictionary *params = @{@"userId":[NSString stringWithFormat:@"%d",self.loginDto.userId]};
    [JZNRequestUtil requestUrl:url requestParams:params success:^(DataResult *dataResult) {
       if(dataResult.code == 0){
           
           NSString *clear = [NSString stringWithFormat:@"findLearn(%@)",[dataResult.data mj_JSONString]];
           [self.jznWebView evaluateJavaScript:clear completionHandler:nil];
       }else {
       }
    } failure:^(NSError *error) {
           
    }];
}

@end
